package com.example.lanqiaodemo1.JavaTest7;

import java.io.*;

public class OutIn3 {

    public static void out3() throws Exception {
        File f = new File("d:\\out3.txt");
        FileOutputStream fos = new FileOutputStream(f);
        for (int i = 1; i <= 100; i++) {
            String a = String.valueOf(i);
            byte[] buf = a.getBytes();
            fos.write(buf);
        }
        fos.close();
    }

    public static void in3() throws Exception {
        File f = new File("d:\\out3.txt");
        FileInputStream fis = new FileInputStream(f);
        int n = 0;
        while ((n = fis.read()) != -1) {
            System.out.print((char) n);
        }
        fis.close();
    }

    public static void main(String[] args) throws IOException {
        try {
            OutIn3.out3();
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            OutIn3.in3();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}